/**
 * 
 */
package com.cross.plateform.common.rpc.core.server.handler.factory;

import com.cross.plateform.common.rpc.core.server.handler.RpcServerHandler;
import com.cross.plateform.common.rpc.core.server.handler.impl.RpcServerHandlerImpl;

/**
 * @author liubing1
 *
 */
public class CommonRpcServerHandlerFactory {
	
	private static RpcServerHandler[] serverHandlers = new RpcServerHandler[2];
	
	static{
		registerProtocol(RpcServerHandlerImpl.TYPE, new RpcServerHandlerImpl());
	}
	
	private static void registerProtocol(int type,RpcServerHandler customServerHandler){
		if(type > serverHandlers.length){
			RpcServerHandler[] newServerHandlers = new RpcServerHandler[type + 1];
			System.arraycopy(serverHandlers, 0, newServerHandlers, 0, serverHandlers.length);
			serverHandlers = newServerHandlers;
		}
		serverHandlers[type] = customServerHandler;
	}
	
	public static RpcServerHandler getServerHandler(){
		return serverHandlers[0];
	}

}
